import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import '../page/home/logic.dart';

class HomeCards extends StatelessWidget {
  HomeCards({super.key});
  final HomeLogic _logic = Get.find<HomeLogic>();

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 100,
      width: double.infinity,
      child: Row(
        children: [
          Expanded(
            child: InkWell(
              child: Obx(() => cardBuildWidget(value: _logic.deliverRemind.value)),
              onTap: () {
                _logic.pushToDeliver();
              },
            ),
          ),
          SizedBox(width: 10),
          Expanded(
            child: InkWell(
                child: Obx(() => cardBuildWidget(backImage: "home_reciver_back", iconsImage: "home_reciver_title", value: _logic.receiverRemind.value)),
                onTap: () {
                  _logic.pushToReceiver();
                }),
          )
        ],
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        mainAxisSize: MainAxisSize.max,
      ),
    );
  }

  /*
  * 一个卡片
  * */
  Widget cardBuildWidget({String backImage = "home_deliver_back", String iconsImage = "home_deliver_title", String value = ""}) {
    return Container(
      decoration: BoxDecoration(image: DecorationImage(image: AssetImage(MGImage.image(backImage, type: ImagePathType.home)))),
      child: Padding(
        padding: EdgeInsets.only(left: 16, right: 16, top: 10, bottom: 10),
        child: Column(
          children: [
            Image.asset(
              MGImage.image(iconsImage, type: ImagePathType.home),
              height: 17,
            ),
            SizedBox(height: 10),
            Text(
              value,
              style: TextStyle(color: MGColors.whileColor, fontSize: MGFont.textFont3),
            )
          ],
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
        ),
      ),
    );
  }
}
